using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using YayiMgr.Ability.Docking.Commom;
using YayiMgr.Ability.Docking.CompanyApp;
using YayiMgr.Ability.Docking.CompanyApp.Dto;

namespace YayiMgr.Web.Controllers.Users
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class CompanyController : ControllerBase
    {
        public ICompanyServicer CompanyServicer { get; set; }

        [HttpGet]
        public async Task<QueryListDto<CompanyDto>> Get()
        {
            return await CompanyServicer.GetAllCompanys();
        }

        [HttpPost]
        public async Task<QueryListDto<CompanyDto>> Get(CompanyQueryDto dto)
        {
            return await CompanyServicer.GetCompanys(dto);
        }

        [HttpGet("{id}")]
        public async Task<ResponseDto<CompanyDto>> Get(Guid Id)
        {
            return await CompanyServicer.GetCompanyById(Id);
        }

        [HttpPost]
        public async Task<ResponseDto<CompanyDto>> Post(CompanyCreateDto dto)
        {
            return await CompanyServicer.AddCompany(dto);
        }

        [HttpPut]
        public async Task Put(Guid Id, CompanyUpdateDto dto)
        {
            await CompanyServicer.UpdateCompany(Id,dto);
        }

        [HttpDelete]
        public async Task Delete(Guid Id)
        {
            await CompanyServicer.DeleteCompany(Id);
        }
    }
}